package com.etc.service;

import com.etc.dao.SysUserDao;
import com.etc.entity.SysUser;
import com.etc.utils.MybaitsUtils;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * @Author kalista
 * @Description 用户业务层
 * @Date 2020/12/16  16:53
 **/
public class SysUserService {

    //用户持久层
    private  SysUserDao sysUserDao;

    public SysUserService(){
        sysUserDao = MybaitsUtils.openSession().getMapper(SysUserDao.class);
    }



    /**
     * 根据用户名进行登录
     * @param username
     * @return
     */
    public SysUser login(String username){
        List<SysUser> userName = sysUserDao.getUserName(username);
        if (userName != null && !userName.isEmpty()){
            return userName.get(0);
        }
        return null;
    }


    /**
     * 添加操作
     * @param sysUser
     * @return
     */
    public Integer add(SysUser sysUser){
        Integer add = sysUserDao.add(sysUser);
        return add;
    }

}
